<?php
/**
 * Created by PhpStorm.
 * Script Name: MaterialNews.php
 * Create: 2023/1/5 15:49
 * Description:
 * Author: fudaoji<fdj@kuryun.cn>
 */

namespace plugin\wechat\app\validate;

use app\common\validate\Common;

class MaterialNews extends Common
{
    public function __construct()
    {
        parent::__construct();
        $this->rule = array_merge([
            'title' => 'require|max:32',
            'thumb_url' => 'require|url',
            'thumb_media_id' => 'require|max:200',
            'source_url' => 'url',
            'digest' => 'max:64',
            'author' => 'max:20',
            'content' => 'require',
        ],
            $this->rule
        );
        $this->message = array_merge([
            'title.require' => '标题必填',
            'title.max' => '标题长度不超过32',
            'thumb_url.require' => '请上传封面图',
            'thumb_url.url' => '封面图无效',
            'thumb_media_id.require' => '封面图media_id丢失',
            'thumb_media_id.max' => '封面图media_id非法',
            'source_url.url' => '跳转链接格式非法',
            'digest.max' => '摘要长度不超过64',
            'author.max' => '作者长度不超过20',
            'content.require' => '文章内容必填',
        ],
            $this->message
        );
    }

    public function sceneAdd()
    {
        return $this->only(['title', 'thumb_media_id', 'thumb_url', 'source_url', 'digest', 'content', 'author']);
    }
}